package com.czz.portal.controller;

import com.czz.common.exception.ResultCodeEnum;
import com.czz.common.vo.R;
import com.czz.portal.entity.CourseDescription;
import com.czz.portal.service.CourseDescriptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: CourseDescriptionController
 * @Author Czz
 * @Date 2020/2/8
 * @Time 18:20
 **/
@RestController
@RequestMapping(value = "/description")
public class CourseDescriptionController {

    @Autowired
    CourseDescriptionService courseDescriptionService;

    /**
    * @Description 根据课程id获取课程描述
    * @Param [id]
    * @Return com.czz.common.vo.R
    * @Author Czz
    * @Date 2020/2/17
    * @Time 11:45
    **/
    @GetMapping(value = "{id}")
    public R getDescriptionByCourseId(@PathVariable String id){
        if (StringUtils.isEmpty(id)){
            return R.setResult(ResultCodeEnum.INPUT_ERROR);
        }
        CourseDescription description = courseDescriptionService.getDescriptionByCourseId(id);
        return R.ok().data("item",description);
    }
}
